package com.espirit.hr;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import com.espirit.eap.annotation.DomainModel;
import com.espirit.eap.manager.Department;
import com.espirit.eap.sa.Employee;

@Entity
@DomainModel
public class DutyRecord implements Serializable{
	private static final long serialVersionUID = 3497477842608077750L;

	private Integer id;
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	
	@ManyToOne
	public Employee getEmployee() {
		return employee;
	}
	public void setEmployee(Employee employee) {
		this.employee = employee;
	}

	public Date getCreated() {
		return created;
	}
	public void setCreated(Date created) {
		this.created = created;
	}
	
	
	@ManyToOne
	public Department getDepartment() {
		return department;
	}
	public void setDepartment(Department department) {
		this.department = department;
	}


	public BigDecimal getHours() {
		return hours;
	}
	public void setHours(BigDecimal hours) {
		this.hours = hours;
	}

	@OneToMany(targetEntity = DutyRecordItem.class ,orphanRemoval = true, fetch=FetchType.LAZY,  cascade = CascadeType.ALL, mappedBy = "parent")
	public List<DutyRecordItem> getChildren() {
		return children;
	}
	public void setChildren(List<DutyRecordItem> children) {
		this.children = children;
	}


	public Date getDutyOn() {
		return dutyOn;
	}
	public void setDutyOn(Date dutyOn) {
		this.dutyOn = dutyOn;
	}


	private Department department;
	private Employee employee;
	private Date created;
	private BigDecimal hours;
	private List<DutyRecordItem> children ;
	private Date dutyOn;

}
